package com.qianfeng.vhly.youshare;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import com.qianfeng.vhly.youshare.fragments.StorePlatformFragment;

/**
 * Created with IntelliJ IDEA.
 * User: vhly[FR]
 * Date: 15/2/7
 * Email: vhly@163.com
 */
public class SubCategoryActivity extends FragmentActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sub_category);

        // 第一步通过 平台产品分类点击，进入到这个界面；
        // 进入之后，传递一个点击的那个分类的ID，
        // 更新StorePlatformFragment 的设计，
        // 使其支持动态的分类列表获取

        Intent intent = getIntent();

        // 获取分类ID

        String cid = intent.getStringExtra(Constants.INTENT_KEY_CATEGORY_ID);
        if (cid == null) {
            cid = "2";
        }

        FragmentManager fragmentManager = getSupportFragmentManager();
        // 开启事务

        FragmentTransaction transaction = fragmentManager.beginTransaction();

        StorePlatformFragment fragment = new StorePlatformFragment();

        // 设置子分类ID，用于显示特定分类下的内容

        Bundle args = new Bundle();
        // 设置子分类ID
        args.putString(Constants.ARG_SUB_CATEGORY_ID, cid);

        fragment.setArguments(args);

        transaction.add(R.id.sub_category_container, fragment);

        transaction.commit();
    }
}